﻿<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24LocationService/Map24LocationService.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


// Sprache
$Language		 = 'de';


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];


// definition of the request body
$request = new GetLocationLayersRequest();
$request->Language = $Language;


// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$maploc = new Map24LocationService($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $maploc->getLocationLayers($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


// get the assignment of theme-id to symbole-id

$poithemes = file('theme_id-symbol_id.csv');
array_shift($poithemes);

$poitheme_ids = array();
foreach ( $poithemes AS $row )
{
	$tmp = explode(",",$row);
	$key = $tmp[1];
	$poitheme_ids[$key] = $tmp[3];
}

// reder the output

if( isset($response->Map24Layers) )
{
	foreach ($response->Map24Layers as $result)
	{
		$resultString .= "<div style='border:1px solid black;margin:2px 0px;padding:5px;'>";
		$resultString .= "<img src='http://img.map24.com/map24/portal/symbols/poi_" . $poitheme_ids[$result->LayerID] . ".png'><p>";
		$resultString .= "LayerID: " . $result->LayerID . "<br />";
		$resultString .= "Name: " . $result->Name . "<br />";
		$resultString .= "Description: " . $result->Description . "<br /><br />";
		$resultString .= "</div>";
	}
}
else
{
	$resultString = "Sorry, no layers found";
}


?>